// import 'dart:html';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../../service/service_method.dart';

class BookPage extends StatefulWidget {
  BookPage({Key key}) : super(key: key);

  @override
  _BookPageState createState() => _BookPageState();
}

class _BookPageState extends State<BookPage> {
  List bookList = [];
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    getBookPage().then((value) {
      setState(() {
        this.bookList = value;
      });
    });
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Column(
        children: <Widget>[
          //页面内容
          Container(
              padding: EdgeInsets.fromLTRB(20, 0, 20, 0),
              height: ScreenUtil().setHeight(700),
              child: ListView.builder(
                itemCount: bookList.length,
                itemBuilder: (context, index) {
                  return Column(
                    children: <Widget>[
                      Container(
                        padding: EdgeInsets.fromLTRB(0, 15, 0, 15),
                        height: ScreenUtil().setHeight(180),
                        child: Stack(
                          children: <Widget>[
                            Positioned(
                              left: 0,
                              child: Container(
                                width: ScreenUtil().setWidth(200),
                                height: ScreenUtil().setHeight(125),
                                child: Image.network(
                                  bookList[index]["img"],
                                  fit: BoxFit.cover,
                                ),
                              ),
                            ),
                            Positioned(
                              left: 120,
                              top: 10,
                              child: Container(
                                height: ScreenUtil().setHeight(125),
                                child: Column(
                                  mainAxisAlignment: MainAxisAlignment.start,
                                  crossAxisAlignment: CrossAxisAlignment.start,
                                  children: <Widget>[
                                    Text(
                                      "${bookList[index]["name"]}",
                                      style: TextStyle(
                                        fontSize: 18,
                                      ),
                                    ),
                                  ],
                                ),
                              ),
                            ),
                            Positioned(
                              right: 0,
                              bottom: 30,
                              child: Container(
                                height: 20,
                                width: 60,
                                child: RaisedButton(
                                  padding: EdgeInsets.fromLTRB(0, 0, 0, 0),
                                  textColor: Colors.white,
                                  child: Text(
                                    "进入",
                                    textAlign: TextAlign.center,
                                    style: TextStyle(
                                      fontSize: 12,
                                    ),
                                  ),
                                  onPressed: () {
                                    //路由跳转
                                    Navigator.pushNamed(context, '/bookcatalog',
                                        arguments: {
                                          "id": "${bookList[index]['id']}"
                                        });
                                  },
                                  color: Colors.blue,
                                  shape: RoundedRectangleBorder(
                                      borderRadius: BorderRadius.circular(15)),
                                ),
                              ),
                            )
                          ],
                        ),
                        decoration: BoxDecoration(
                          border: Border(
                            bottom: BorderSide(
                              width: 0.5,
                              color: Color.fromRGBO(240, 240, 240, 1)
                            ),
                          ),
                        ),
                      ),
                      // Stack(
                      //   children: <Widget>[
                      //     Row(
                      //       children: <Widget>[
                      // Container(
                      //   width: ScreenUtil().setWidth(200),
                      //   height: ScreenUtil().setHeight(125),
                      //   child: Image.network(bookList[index]["img"]),
                      // ),
                      //         SizedBox(width: 25),
                      // Container(
                      //   height: ScreenUtil().setHeight(125),
                      //   child: Column(
                      //     mainAxisAlignment: MainAxisAlignment.start,
                      //     crossAxisAlignment: CrossAxisAlignment.start,
                      //     children: <Widget>[
                      //       Text(
                      //         "${bookList[index]["name"]}",
                      //         style: TextStyle(
                      //           fontSize: 18,
                      //         ),
                      //       ),
                      //     ],
                      //   ),
                      // ),
                      //         Positioned(child: null),
                      //         // Positioned(
                      //         //   right: 20,
                      //         //   // margin: EdgeInsets.fromLTRB(75, 0, 0, 0),
                      // child: Container(
                      //   height: 20,
                      //   width: 60,
                      //   child: RaisedButton(
                      //     padding: EdgeInsets.fromLTRB(0, 0, 0, 0),
                      //     textColor: Colors.white,
                      //     child: Text(
                      //       "进入",
                      //       textAlign: TextAlign.center,
                      //       style: TextStyle(
                      //         fontSize: 12,
                      //       ),
                      //     ),
                      //     onPressed: () {
                      //       //路由跳转
                      //       Navigator.pushNamed(
                      //           context, '/bookcatalog', arguments: {
                      //         "id": "${bookList[index]['id']}"
                      //       });
                      //     },
                      //     color: Colors.blue,
                      //     shape: RoundedRectangleBorder(
                      //         borderRadius:
                      //             BorderRadius.circular(15)),
                      //   ),
                      // ),
                      // ),
                      //       ],
                      //     ),
                      //   ],
                      // ),
                      SizedBox(height: 18)
                    ],
                  );
                },
              ))
        ],
      ),
    );
  }
}
